package ThreadPerMessage.Q7;



public class Blackhole {
    public static void enter(Object obj) {
        System.out.println("Step 1");
        magic(obj);
        System.out.println("Step 2");
        synchronized (obj) {
            System.out.println("Step 3 (never reached here)");  
        }
    }

    public static void magic(final Object obj) {
    	for (int i = 0; i < 10; i++) {
        	new Thread(new Runnable() {
    			
    			@Override
    			public void run() {
    				while (true) {
    					obj.getClass();
    				}
    			}
    		}).start();
		}
    	try {
			Thread.sleep(3000);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
    }
}
